Add Python venv setup script and fix pyproject.toml#322
Add Python venv setup script and fix pyproject.toml#322krystophny wants to merge 1 commit intomainfrom
Conversation
ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan Review Summary by QodoAdd Python venv setup script and fix dependency constraints
WalkthroughsDescription• Add setup-venv.sh script to automate Python venv creation with dependencies • Add make venv and make venv-nopy targets for convenient environment setup • Replace exact version pins with minimum constraints in requirements.txt • Remove invalid [project.package-data] section from pyproject.toml • Add .venv/ directory to .gitignore Diagramflowchart LR
A["setup-venv.sh script"] -->|creates| B[".venv directory"]
B -->|installs| C["Python dependencies"]
C -->|builds| D["pysimple bindings"]
E["Makefile targets"] -->|calls| A
F["requirements.txt"] -->|minimum versions| C
G["pyproject.toml"] -->|remove invalid section| H["valid config"]
File Changes1. setup-venv.sh
|
Code Review by Qodo
1. Stale CMake disables bindings
|
| if [ ! -f "${SCRIPT_DIR}/build/build.ninja" ]; then | ||
| echo " Configuring CMake ..." | ||
| cmake -S "$SCRIPT_DIR" -B"${SCRIPT_DIR}/build" -GNinja \ | ||
| -DCMAKE_BUILD_TYPE=Release -DCMAKE_COLOR_DIAGNOSTICS=ON | ||
| fi | ||
| echo " Building Fortran library ..." | ||
| cmake --build "${SCRIPT_DIR}/build" --config Release | ||
|
|
||
| echo " Installing pysimple in editable mode ..." | ||
| pip install --no-build-isolation -e "$SCRIPT_DIR" |
There was a problem hiding this comment.
1. Stale cmake disables bindings 🐞 Bug ✓ Correctness
setup-venv.sh only configures CMake when build/build.ninja is missing, so an existing build/ configured with ENABLE_PYTHON_INTERFACE=OFF can be reused and pysimple won’t be built correctly. This can lead to pip install -e . producing a package that fails to import because the python/ subdirectory is skipped by CMake.
Agent Prompt
### Issue description
`setup-venv.sh` reuses an existing `build/` directory if `build/build.ninja` exists, without ensuring `-DENABLE_PYTHON_INTERFACE=ON`. If a developer previously ran `make build-deterministic-nopy` (which configures `build/` with `ENABLE_PYTHON_INTERFACE=OFF`), the venv setup will reuse that cache and the Python bindings won’t be built/installed correctly.
### Issue Context
- `Makefile` has a `build-deterministic-nopy` target that configures `build/` with `-DENABLE_PYTHON_INTERFACE=OFF`.
- Top-level `CMakeLists.txt` only adds `python/` when `ENABLE_PYTHON_INTERFACE` is enabled.
- `pyproject.toml` sets scikit-build-core `build-dir = "build"`, so pip editable installs will interact with the same build directory.
### Fix Focus Areas
- setup-venv.sh[46-58]
- Makefile[73-85]
- pyproject.toml[13-19]
### Implementation direction
Do one of the following (preferred options first):
1. Use a dedicated build directory for the venv workflow (e.g. `build_venv/`), so it cannot conflict with `make build-deterministic-nopy`.
2. Always run an explicit reconfigure step when `BUILD_PYSIMPLE=1`, passing `-DENABLE_PYTHON_INTERFACE=ON` (and optionally `-DSIMPLE_ENABLE_PYTHON_TOOLS=ON`) even when `build/build.ninja` exists.
3. Detect a cached `CMakeCache.txt` with `ENABLE_PYTHON_INTERFACE:BOOL=OFF` and either error out with a clear message or automatically reconfigure/clean.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Add setup-venv.sh that creates .venv with all Python dependencies (scipy, netCDF4, matplotlib, f90wrap, etc.) and builds pysimple Fortran-Python bindings. Adds `make venv` and `make venv-nopy` targets. Also fixes: - requirements.txt: use minimum version constraints instead of exact pins, which break on newer Python versions (e.g., 3.14) that lack prebuilt wheels for the pinned versions - pyproject.toml: remove invalid [project.package-data] section that newer scikit-build-core (>=0.12) rejects as an unknown key - .gitignore: add .venv/
31cfad8 to
50a0fce
Compare
Summary
setup-venv.shscript that creates.venvwith all Python dependencies and builds pysimplemake venv/make venv-nopytargetsrequirements.txt: use minimum version constraints instead of exact pins (exact pins break on Python 3.14 due to missing prebuilt wheels)pyproject.toml: remove invalid[project.package-data]section rejected by scikit-build-core >= 0.12.venv/to.gitignoreTest plan
./setup-venv.shcreates working venv with pysimplesource .venv/bin/activate && make testpasses all tests (including previously-failing Python tests)./setup-venv.sh --no-pysimpleworks for deps-only install